<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
		<title>
			<c:if test="${member.userType eq '1'}">预约-个人</c:if>
			<c:if test="${member.userType eq '0'}">预约-企业</c:if>
		</title>
		<link rel="stylesheet" href="<c:url value='/resource/wechat/css/frozen.css'></c:url>">
		<link rel="stylesheet" href="<c:url value='/resource/wechat/css/main.css'></c:url>">
	</head>

	<body>

		<section class="ui-container">
			<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
				<label class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; ">${caseInfo.caseName}</label>
			</div>
			<c:if test="${member.userType eq '1'}">
			<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
				<label>姓<span class="text_white">姓名</span>名：</label>
				<input type="text" placeholder="" value="${member.aliasName}" disabled>
			</div>
			<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
				<label>身份证号：</label>
				<input type="text" placeholder="" id="idCard" value="${member.userCode}" disabled>
			</div>
			<div class="ui-form-item ui-form-item-show ui-border-b bg_fff" disabled>
				<label>手机号码：</label>
				<input type="text" placeholder="" value="${member.userName}" disabled>
			</div>
<%--			<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
				<label>联系地址：</label>
				<input type="text" placeholder="" value="${member.address}" disabled>
			</div>--%>
			<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
				<label>联系地址：</label>
				<textarea cols="3" style="text-align: left; vertical-align: middle" disabled>${member.address}</textarea>
			</div>
			</c:if>

			<c:if test="${member.userType eq '0'}">
				<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
					<label>企业名称：</label>
					<input type="text" placeholder="" value="${member.aliasName}" disabled>
				</div>
				<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
					<label>企业代码：</label>
					<input type="text" placeholder="" value="${member.userCode}" disabled>
				</div>
				<%--<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
					<label>联<span class="text_white">联</span>系人：</label>
					<input type="text" placeholder="" value="${member.contacts}" disabled>
				</div>--%>
				<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
					<label>手机号码：</label>
					<input type="text" placeholder="" value="${member.mobile}" disabled>
				</div>
				<div class="ui-form-item ui-form-item-show ui-border-b bg_fff">
					<label>联系地址：</label>
					<input type="text" placeholder="" value="${member.address}" disabled>
				</div>

			</c:if>
			<form id="uploadForm" enctype="multipart/form-data" method="post">
				<input type="hidden" name="pt" value="${pt}"/>
				<input type="hidden" name="userGuid" value="${userGuid}"/>
				<input type="hidden" name="caseNo" value="${caseNo}"/>
				<input type="hidden" name="orgid" value="${orgid}"/>
				<input type="hidden" name="addr" value="${member.address}"/>
			<%--	<c:if test="${sxlb!=null && fn:length(sxlb) >0}">
					<div id="fjTitle" class="ui-form-item ui-form-item-show ui-border-tb bg_fff"
						 style="margin-top: 10px;">
						<label class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; ">请上传附件</label>
					</div>
					<div id="sxlb" class="bg_fff ui-border-b" style="overflow: hidden;">
					<table width="100%" border="0" cellspacing="0" cellpadding="0" class="order_table">
							<c:forEach var="material" items="${sxlb}" varStatus="status">
								<tr>
									<td>
											${material.material}
											<c:if test="${material.ismust == '1'}">
												<span style="color:red">*（必需）</span>
											</c:if>
									</td>
								</tr>
								<tr>
									<td>
										<input type="file" accept="image/jpg,image/jpeg,image/png,image/gif" capture="camera" onchange="readFile(this,'${status.index}')"
											   name="fileName" id="fileName${status.index}"/>
											&lt;%&ndash;<input type="file" accept="image/jpg,image/jpeg,image/png,image/gif" multiple="" onchange="changeimg(this.files,'${material.guid}')" name="uploadfile">&ndash;%&gt;
											&lt;%&ndash;<input id="fileElem1" pictype='30010003' data-role="none" type="file" name="idFile" accept="image/jpg,image/jpeg,image/png,image/gif" />&ndash;%&gt;
										<input type="hidden" name="fileValue${status.index}" id="fileValue${status.index}"/>

										<input type="hidden" value="${material.guid}" name="guid${status.index}" id="guid${status.index}"/>
										<input type="hidden" value="${material.rownum}" name="sort${status.index}" id="sort${status.index}"/>
										<input type="hidden" value="${material.ismust}" name="must${status.index}" id="must${status.index}"/>
										<input type="hidden" value="${material.material}" name="material${status.index}" id="material${status.index}"/>
									</td>
								</tr>
							</c:forEach>
						</table>
					</div>
				</c:if>--%>

			<div class="ui-form-item ui-form-item-show ui-border-tb bg_fff" style="margin-top: 10px;">
				<label class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; ">请选择一个预约日期</label>
			</div>
				<div class="bg_fff ui-border-b" style="overflow: hidden;height: 35px;">
					<select id="yyTime" name="yyTime"
							style="width: 50%; border: 0px; height: 100%; text-indent: 5px;float: left; display: inline">
						<c:forEach var="rq" items="${yyrq}">
							<option value="${rq}">${rq}</option>
						</c:forEach>
					</select>
				</div>
			<div class="ui-form-item ui-form-item-show ui-border-tb bg_fff" style="margin-top: 10px;">
				<label class="h1_text" style="width: 80%;color: #2775fb; font-size: 16px; ">请选择一个时间段</label>
			</div>
			<div class="bg_fff ui-border-b" style="overflow: hidden;">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="order_table">
					<tr>
						<td>选择</td>
						<td>时间段</td>

					</tr>
					<tr>
						<td>
							<input type="radio" name="checkbox" id="checkbox1" checked value="上午">
						</td>
						<td><label for="checkbox1">上午</label></td>
					</tr>
					<tr>
						<td>
							<input type="radio" name="checkbox" id="checkbox2" value="下午">
						</td>
						<td><label for="checkbox2">下午</label></td>

					</tr>
				</table>
			</div>
			</form>
			 <div class="ui-btn-wrap">
    <button class="ui-btn-lg ui-btn-primary" id="orderButton" >
        预约
    </button>
	</div>



		</section>
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<%--<script src="<c:url value="/resource/wechat/js/frozen.js"/>"></script>--%>
	<script type="text/javascript">
		var fileNum = -1;
		var base64 = "";
		// 必须上传的file编号，逗号分隔
		var isMust = "${ismust}";
		//var j = 0;
		$(function(){
			$("#orderButton").bind("click",function(){
				orderItem();
			});
		})
		function readFile(obj,index){
			var file = obj.files[0];
			//判断类型是不是图片
			if(!/image\/\w+/.test(file.type)){

				$("#fileValue"+index).val("");
				obj.outerHTML = obj.outerHTML.replace(/(value=\").+\"/i, "$1\"");
				alert("请确保文件为图像类型");
				return false;
			}
			/*var reader = new FileReader();
			reader.readAsDataURL(file);
			reader.onload = function(e){
				if(size>0){
					$("#fileValue"+index).val(name+"|"+size+"|"+$("#guid"+index).val()+"|"+$("#sort"+index).val()+"|"+$("#must"+index).val()+"|"+$("#material"+index).val()+"|"+this.result);
				}
			}*/
		}

		function orderItem(){
            if(isMust!=""){
                var must = isMust.split(",");
                for(var i = 0; i< must.length; i++){

                    if($("#fileName"+must[i]).val()==""){
                        alert("请上传必需的材料图片");
                        return false;
                    }
                }
            }
			$("#orderButton").unbind();
			$("#orderButton").attr("disabled",true);
			var formData = new FormData($( "#uploadForm" )[0]);

			$.ajax({
				type : "POST",
				url : '<c:url value="/api/project/doarrangement"/>',
				//data : '{"userGuid":"'+userGuid+'","caseNo":"'+caseNo+'","orgId":"'+orgid+'","addr":"'+addr+'","yyTime":"'+ yyTime+'","yySpan":"'+yySpan+'","file":"'+base64+'","pt":"'+pt+'"}',
				data : formData,
				processData: false,  // 告诉jQuery不要去处理发送的数据
				contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
				async : false,
				cache: false,
				success : function(resp){
					if(resp&&resp.succ){
						alert("预约成功！");
						$("#orderButton").html(resp.msg);
						window.location.href="<c:url value='/api/police/myorder?userGuid=${userGuid}' />";
					}else {
						$("#orderButton").html(resp.msg+"，请重试！");
						$("#orderButton").attr("disabled",false);
						$("#orderButton").bind("click",function(){
							orderItem();
						});
						//window.location.href="<c:url value='/api/case/index'/>";
					}
				},
				error : function(XMLHttpRequest, textStatus,errorThrown) {
					alert(errorThrown);
				}
			});
		}
	</script>

</html>